package com.lhr.controller;

import com.lhr.entity.Menu;
import com.lhr.response.Result;
import com.lhr.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author LiHuiRu
 * @since 2023-02-21
 */
@Api(tags = "菜单权限接口")
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @ApiOperation(value = "加载菜单树", notes = "获取所有菜单树，以及展开项")
    @GetMapping("/tree")
    public Result tree() {
        //1.查询所有的菜单
        List<Menu> menuTree = menuService.findMenuTree();

        //2.查询哪些菜单是展开的
        List<Long> ids = menuService.findOpenIds();

        return Result.ok().data("menuTree", menuTree);
    }
}
